import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Solution1177 {
    public List<Boolean> canMakePaliQueries(String s, int[][] queries) {
        int[][] f=new int[s.length()+1][26];
        for (int i=0;i<s.length();i++){
            System.arraycopy(f[i],0,f[i+1],0,26);
            f[i+1][s.charAt(i)-'a']++;
        }
        List<Boolean> ans=new ArrayList<>();
        for (int[] query : queries) {
            int[] g=new int[26];
            for (int i=0;i<26;i++){
                g[i]=f[query[1]+1][i]-f[query[0]][i];
            }
            Arrays.sort(g);
            if ((query[1]-query[0])%2==0){
                for (int i=25;i>=0;i--){
                    if (g[i]%2==1){
                        g[i]--;
                        break;
                    }
                }
            }
            int count=0;
            for (int i=25;i>=0;i--){
                if (g[i]%2==1){
                    count++;
                }
            }
            ans.add(count/2<=query[2]);
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1177().canMakePaliQueries("abcda",new int[][]{{3,3,0},{1,2,0},{0,3,1},{0,3,2},{0,4,1}}));
    }
}
